﻿using Microsoft.Extensions.Localization;
using Thinker.SignChannel.Dto;

namespace Thinker.SignChannel.Records;

public class RecordExcelDto
{
    public string? RecordTime { get; set; }
    public string? IdNumber { get; set; }
    public string? PersonName { get; set; }

    public string? Sex { get; set; }
    public string? PersonCode { get; set; }
    public string? PersonType { get; set; }

    public string? SignDate { get; set; }
    public string? Period { get; set; }
    public string? Direction { get; set; }
    public string? SignTime { get; set; }

    public static RecordExcelDto From(RecordInfo info, IStringLocalizer localizer)
    {
        var record = info.Record;
        return new RecordExcelDto
        {
            RecordTime = record.RecordTime.ToDisplay(),
            IdNumber = record.IdNumber,
            PersonName = record.PersonName,

            Sex = info.Person?.Sex,
            PersonCode = info.Person?.PersonCode,
            PersonType = info.Person?.PersonType,

            SignDate = info.Time?.SignDate.ToDisplay(),
            Period = info.Time?.Period,
            Direction = info.Time?.Direction.ToDisplay(localizer),
            SignTime = info.Time?.SignTime.ToDisplayOnlyTime()
        };
    }
}